import { Field, generateFiledString } from "./Field";

/**
 * 一张数据表
 */
export class Table {
  name: string
  fields: Field[] = [];


  constructor(name: string) {
    this.name = name;
  }

  generateCreateSql(): string {
    let sql = `CREATE TABLE IF NOT EXISTS ${this.name} `;
    const filedInfos = this.fields.map(f => generateFiledString(f));
    sql += ` (${filedInfos.join(" , ")});`
    return sql;
  }
}
